#include <bits/stdc++.h>
#define ll long long
#define pr printf
#define sc scanf
using namespace std;
char a[15], b[15], temp[15], c[15];
char *itos(int x, char *p)
{
	int i = 0, j = 0;
	char dis[15];
	while (x > 0)
	{
		dis[i++] = x % 10 + '0';
		x /= 10;
	}
	while (i > -1)
		p[j++] = dis[--i];
	p[j] = '\0';
	return p;
}
void change(char *p, int num)
{
	int len, i;
	len = strlen(itos(num, temp));
	for (i = 0; i < 4 - len; i++)
		p[i] = '0';
	p[i] = '\0';
	strcat(p, temp);
	return;
}
int main()
{
	int ans, len, i, ori;
	sc("%d", &ori);
	getchar();
	change(a, ori);
	strcpy(b, a);
	while (1)
	{
		sort(a, a + 4, greater<char>());
		sort(b, b + 4, less<char>());
		ans = atoi(a) - atoi(b);
		change(c, ans);
		printf("%s - %s = %s\n", a, b, c);
		if (ans == 6174 || ans == 0)
			break;
		strcpy(a, c);
		strcpy(b, a);
	}
	return 0;
}
